home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
- /*
- * File: vidpaint.c
- *
- * uses much of 4Dgifts example,
- * contcapt.c for much of VL code.
- *
- * last modified 2/22/94 atang
- * 4/6/94 atang even field capture
- *
- */
-
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdlib.h>
-
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
- #include <getopt.h>
- #include <sys/time.h>
- #include <gl/gl.h>
- #include <gl/device.h>
- #include <gl/image.h>
-
- #include <vl/vl.h>
-
- #define VL_PACKING_INVALID -1
- #define Debug if (debug) printf
- #define TIME_ARRAY_SIZE 400 /* MUST be divisible by 5! */
- #define TIME_GRANULARITY 1000
- #define PAINT 0
- #define COMPOUND 1
-
-
- void ProcessEvent(VLServer, VLEvent *, void *);
- void ProcessGlEvent(int, void *);
- int pause(void);
- void exitcapture(void);
-
- /*
- * Global variables
- */
- char *cmdargs = "b:c:dDeFg:hi:mn:o:p:r:tv:wz:";
- char *usage_m =
- "usage: %s %s\n"
- "where arguments may be:\n"
- " -b n use n buffers\n"
- " -c n capture n frames\n"
- " -d turn off double buffer mode\n"
- " -D turn on debug mode (displays more information)\n"
- " -e turn OFF even fields only mode\n"
- " -F specifies field (or non-interleaved) mode\n"
- " -i n report statistics every n frames\n"
- " -m monochrome input\n"
- " -n n device number n \n"
- " -o n video output source to use (depends on hardware)\n"
- " -p n set win position (1=upperLHS,0=lowerLHS(default))\n"
- " -r n set frame rate to n\n"
- " -t turn on timing statistics gathering\n"
- " -v n video input source to use (depends on hardware)\n"
- " -w 32 bit 'wide' RGB pixels\n"
- " -h this help message\n"
- ;
-
- char *_progName;
- char *deviceName;
- int devicenum = -1;
- int ev1num = -1;
- int buffers = 2;
- int packing = VL_PACKING_INVALID;
- int totalCount = 10000000;
- int debug = 0;
- int double_buffer = 1;
- int fast = 0;
- int fieldmode = 0;
- int evenfields = 1;
- int frameCount;
- int frameInterval = -1;
- int framenumber = 0;
- int lasttime = 0;
- int rate = 0;
- int secs;
- int time_array[TIME_ARRAY_SIZE];
- int time_on = 0;
- int xsize = 0;
- int ysize = 0;
- int zoom_num = 1, zoom_denom = 4; /* set zoom to 1/4 always */
- struct timeval tv_save;
- VLPath vlPath;
- VLServer vlSvr;
- VLNode drn;
- VLNode src;
- VLBuffer transferBuf;
- int mywinposition = 0;
- int effecttype = 0;
- int backcolor = 0;
- int input_timing;
- int vin = VL_ANY;
- int vout = VL_ANY;
- int vinflag = 0;
- int voutflag = 0;
- int yzoommult = 2;
- int rzoom = 1;
-
- long sizex, sizey;
- short dev, val;
- int active=TRUE;
- long win;
- int menu;
- short x=0;
- short y=0;
- short val, leftmousedown;
- int doalpha = 0;
- int pixscale = 1;
- long orgx, orgy;
-
- #define brushx 15
- #define brushy 15
- unsigned long alpha = 0xff000000;
- unsigned long *getframe;
- unsigned long *drawframe;
- unsigned long brush[brushx][brushy];
- int drawcolors = 0; /* plain, funky, negative */
-
-
- prepare_window(){
- RGBmode();
- gconfig();
- cpack(0x00000000);
- clear();
- blendfunction(BF_SA, BF_MSA);
- qdevice(INPUTCHANGE);
- qdevice(REDRAW);
- qdevice(ESCKEY);
- qdevice(WINQUIT);
- qdevice(WINSHUT);
- qdevice(LEFTMOUSE);
- qdevice(MIDDLEMOUSE);
- qdevice(RIGHTMOUSE);
- qdevice(DKEY);
- qdevice(CKEY);
- qdevice(QKEY);
- qdevice(SKEY);
-
- pixmode(PM_TTOB, 1);
- }
-
- initialize() {
-
- int i,j;
- short red,green,blue;
- int vidx,vidy; /* input video size */
-
- if ((input_timing == VL_TIMING_625_SQ_PIX) ||
- (input_timing == VL_TIMING_625_CCIR601) ||
- (input_timing == VL_TIMING_625_4FSC))
- {/* PAL */
- vidx = 768;
- vidy = 576;
- }else
- {/* NTSC */
- vidx = 640;
- vidy = 486;
- }
-
- if (mywinposition == 1)
- {
- prefposition((long)0, (long)(vidx+10), (long)(1023-vidy), (long)1023);
- }else /* lower left */
- {
- prefposition ((long)0, (long)(vidx+10), (long)0, (long)(vidy));
- }
-
- win=winopen("Video Paint");
-
- prepare_window();
-
- getsize(&sizex, &sizey);
- zbuffer(TRUE);
- lsetdepth(0x00, 0x7fffff);
- menu = defpup("Opaque | 25 Pcnt Blend | 6.25 Pcnt Blend | 1x | 2x | 4x | Plain | Funky | Negative | Paint | Multiple | Background Colors | Quit");
-
- return(0);
- }
-
-
- /* code for reading from disk (not currently called) */
- read_img()
- {
- }
-
- draw_scene(short x, short y) {
-
- int i,j, xp, yp;
- unsigned long *prgb;
- unsigned long *dprgb;
- unsigned char *pval;
- short gotalpha,red,blue,green;
-
- /* the alpha code puts alpha values that i want into the */
- /* array returned by VL, but this is inefficient */
-
- for (j=0;j<ysize;j++){
- prgb = &getframe[0] + ((ysize - 1) - j)*xsize;
- for (i=0;i<xsize;i++)
- {
- pval = (unsigned char *)(prgb+i);
- gotalpha = *pval++;
- blue = *pval++;
- green = *pval++;
- red = *pval++;
- switch (drawcolors) {
- case 0:
- *(prgb+i)=red|(green<<8)|(blue<<16)|alpha;
- break;
- case 1:
- *(prgb+i)=red|(green<<11)|(blue<<19)|alpha;
- break;
- case 2:
- *(prgb+i)=(255-red)|((255-green)<<8)|((255-blue)<<16)|alpha;
- break;
- };/* end switch */
- }/* end for i */
- }/* end for j*/
-
- switch (rzoom) /* adjust zoom factors - yzoommult = 2.0 if evenfields*/
- {
- case 1: /* 1x */
- rectzoom(1.0, 1.0*yzoommult);
- break;
- case 2: /* 2x */
- rectzoom(2.0, 2.0*yzoommult);
- break;
- case 4: /* 4x */
- rectzoom(4.0, 4.0*yzoommult);
- break;
- }
-
- switch (effecttype)
- {
- case COMPOUND:
- xp = 20;
- yp = 20;
- for (i = 0; i<3; i++)
- {
- for (j = 0; j<3; j++)
- {
- lrectwrite(i*xsize+i*xp+64, j*ysize*yzoommult+j*yp+48,
- (i+1)*xsize-1+i*xp+64,(j+1)*ysize-1+j*yp+48,
- &getframe[0]);
- }
- }
- break;
- case PAINT:
- default:
- lrectwrite(x, y, xsize-1+x, ysize-1+y, &getframe[0]);
- break;
- }
- }
-
-
- void
- initStatistics(void)
- {
- if (!debug) return;
- gettimeofday(&tv_save);
- }
-
- void
- reportStatistics(void)
- {
- double rate;
- struct timeval tv;
- int delta_t;
-
- /* Delta_t in microseconds */
- delta_t = (tv.tv_sec*1000 + tv.tv_usec/1000) -
- (tv_save.tv_sec*1000 + tv_save.tv_usec/1000);
-
- rate = frameCount*1000.0/delta_t;
-
- printf("got %5.2f frames/sec\n", rate);
- tv_save.tv_sec = tv.tv_sec;
- tv_save.tv_usec = tv.tv_usec;
-
- }
-
- char *
- packing_name (int packtype)
- {
- switch (packtype)
- {
- case VL_PACKING_RGB_8:
- return "RGB";
- break;
-
- case VL_PACKING_RGBA_8:
- return "RGBA";
- break;
-
- case VL_PACKING_RBG_323:
- return "Starter Video RGB8";
- break;
-
- case VL_PACKING_RGB_332_P:
- return "RGB332";
- break;
-
- case VL_PACKING_Y_8_P:
- return "8 Bit Greyscale";
- break;
-
- default:
- return "???";
- break;
- }
- }
-
- getcmdargs(int argc, char **argv)
- {
- int c;
- int len, xlen, ylen;
- char numbuf[5];
- char *xloc;
-
- while ((c = getopt(argc, argv, cmdargs)) != EOF)
- {
- switch (c)
- {
-
- case 'b':
- buffers = atoi(optarg);
- break;
-
- case 'c':
- totalCount = atoi(optarg);
- break;
-
- case 'D':
- debug = 1;
- break;
-
- case 'd':
- double_buffer = 0;
- break;
-
- case 'e':
- evenfields = 0;
- yzoommult = 1;
- break;
-
- case 'f':
- fast = 1;
- break;
-
- case 'F':
- fieldmode = 1;
- break;
-
- case 'g':
- len = strlen(optarg);
- xloc = strchr(optarg, 'x');
- if (!xloc)
- {
- printf("Error: invalid geometry format, using default size\n");
- break;
- }
- xlen = len - strlen(xloc);
- if (xlen < 1 || xlen > 4)
- {
- printf("Error: invalid x size, using default size\n");
- break;
- }
- strncpy(numbuf, optarg, xlen);
- xsize = atoi(numbuf);
-
- ylen = len - xlen -1;
- if (ylen < 1 || ylen > 4)
- {
- printf("Error: invalid y size, using default size\n");
- break;
- }
- strncpy(numbuf, &optarg[xlen + 1], ylen);
- ysize = atoi(numbuf);
- break;
-
- case 'i':
- frameInterval = atoi(optarg);
- printf("frameInterval = %d\n", frameInterval);
- break;
-
- case 'm':
- packing = VL_PACKING_Y_8_P;
- break;
-
- case 'n':
- devicenum = atoi(optarg);
- printf("User specified device number: %d\n", devicenum);
- break;
-
- case 'o':
- vout = atoi(optarg);
- voutflag = 1;
- Debug ("video output = %d\n", vout);
- break;
-
- case 'p':
- mywinposition = atoi (optarg);
- break;
-
- case 'r':
- rate = atoi(optarg);
- break;
-
- case 't':
- time_on = 1;
- break;
-
- case 'v':
- vin = atoi(optarg);
- vinflag = 1;
- Debug ("video input = %d\n", vin);
- break;
-
- case 'w':
- packing = VL_PACKING_RGB_8;
- break;
-
- case 'z': /* we're only supporting z 1/4 for now */
- break;
-
- case 'h':
- default:
- fprintf(stderr, usage_m, _progName, cmdargs);
- exit(0);
- break;
- }
- }
- }
-
- main(int argc, char **argv)
- {
- VLDevList devlist;
- char *deviceName;
- char window_name[128];
- char *xloc;
- long win;
- int c,i;
- int len, xlen, ylen;
- VLControlValue val;
-
-
- _progName = argv[0];
- getcmdargs(argc, argv);
-
- if (time_on)
- for (c = 0; c < 1000; c++)
- time_array[c] = 0;
-
- if (!(vlSvr = vlOpenVideo(""))) {
- printf("couldn't open video\n");
- exit(1);
- }
-
- if (vlGetDeviceList(vlSvr, &devlist) < 0) {
- printf("error getting device list: %s\n",vlStrError(vlErrno));
- exit(1);
- }
-
- /* find ev1 */
- for (i=0; i<devlist.numDevices; i++)
- if (strcmp(devlist.devices[i].name,"ev1") == 0)
- ev1num = i;
- if ( (ev1num == -1) /* no ev1 found ... OR ...*/
- || ((devicenum != -1) && (devicenum != ev1num))) /* non ev1 specified*/
- {
- printf("This program requires 'ev1' hardware.\a\n");
- if (ev1num != -1)
- printf("Use device number '%d', or use the default mode\n",ev1num);
- exit(1);
- }else
- {
- printf("Setting device number to %d\n", ev1num);
- devicenum = ev1num; /* allow default to work */
- }
-
- /* Set up a source node on the specified video source */
- if (vinflag == 0)
- src = vlGetNode(vlSvr, VL_SRC, VL_VIDEO, VL_ANY);
- else
- src = vlGetNode(vlSvr, VL_SRC, VL_VIDEO, vin);
-
- /* Set up a drain node in memory */
- if (voutflag == 0)
- drn = vlGetNode(vlSvr, VL_DRN, VL_MEM, VL_ANY);
- else
- drn = vlGetNode(vlSvr, VL_DRN, VL_MEM, vout);
-
- if ((vlPath = vlCreatePath(vlSvr, devicenum, src, drn)) < 0)
- {
- vlPerror("vlCreatePath");
- exit(1);
- }
-
- if (vlSetupPaths(vlSvr, (VLPathList)&vlPath, 1, VL_SHARE, VL_SHARE) < 0){
- printf ("could not setup a vid to mem path\n");
- exit(1);
- }
-
- /* get the current input timing */
- vlGetControl(vlSvr, vlPath, src, VL_TIMING, &val);
- input_timing = val.intVal;
-
- /* get the name of the device we're using */
- deviceName = devlist.devices[devicenum].name;
- printf("Using device %d (%s)\n", devicenum, deviceName);
-
- val.fractVal.numerator = zoom_num;
- val.fractVal.denominator = zoom_denom;
- vlSetControl(vlSvr, vlPath, drn, VL_ZOOM, &val);
-
- /* Set the frame rate */
- if (rate)
- {
- val.intVal = rate;
- vlSetControl(vlSvr, vlPath, src, VL_RATE, &val);
- }
- vlGetControl(vlSvr, vlPath, src, VL_RATE, &val);
- Debug("frame rate = %d\n", val.intVal);
-
- /*
- * Specify what vlPath-related events we want to receive.
- * In this example we only want transfer complete events.
- */
- vlSelectEvents(vlSvr, vlPath, VLTransferCompleteMask|VLTransferFailedMask);
-
- /* Set up for even frame capture */
- if (evenfields)
- {
- val.intVal = VL_CAPTURE_EVEN_FIELDS;
- if (vlSetControl(vlSvr, vlPath, drn, VL_CAP_TYPE, &val) < 0)
- vlPerror("Seting VL_PACKING");
-
- /* Make sure non-interleaved capture is supported by the harware */
- if (vlGetControl(vlSvr, vlPath, drn, VL_CAP_TYPE, &val) < 0)
- vlPerror("Geting VL_PACKING");
- if (val.intVal != VL_CAPTURE_EVEN_FIELDS)
- fprintf(stderr,"Capture type not set to EVEN_FIELDS: %d\n",
- val.intVal);
- Debug("Field (even) mode\n");
- }
-
- /* Set up for non-interleaved frame capture */
- if (fieldmode)
- {
- val.intVal = VL_CAPTURE_NONINTERLEAVED;
- if (vlSetControl(vlSvr, vlPath, drn, VL_CAP_TYPE, &val) < 0)
- vlPerror("Seting VL_PACKING");
-
- /* Make sure non-interleaved capture is supported by the harware */
- if (vlGetControl(vlSvr, vlPath, drn, VL_CAP_TYPE, &val) < 0)
- vlPerror("Geting VL_PACKING");
- if (val.intVal != VL_CAPTURE_NONINTERLEAVED)
- fprintf(stderr,"Capture type not set to NONINTERLEAVED: %d\n",
- val.intVal);
- Debug("Field (non-interleaved) mode\n");
- }
-
- /* Set the video geometry */
- if (xsize) {
- val.xyVal.x = xsize;
- val.xyVal.y = ysize;
- vlSetControl(vlSvr, vlPath, drn, VL_SIZE, &val);
- }
- vlGetControl(vlSvr, vlPath, drn, VL_SIZE, &val);
- xsize = val.xyVal.x;
- ysize = val.xyVal.y;
- drawframe = (unsigned long *)malloc((ysize*xsize)*(sizeof(unsigned long)));
- if (evenfields)
- ysize = ysize / 2;
- Debug("pre adjusted size %dx%d\n", xsize, ysize);
- if (ysize == 243){
- ysize = ysize - 3;
- }
- if (ysize == 121){
- ysize = ysize - 1;
- }
- val.xyVal.x = xsize;
- val.xyVal.y = ysize;
- vlSetControl(vlSvr, vlPath, drn, VL_SIZE, &val);
- Debug("grabbing size %dx%d\n", xsize, ysize);
-
- /* Set the packing type for the video board */
- if (packing != VL_PACKING_INVALID)
- {
- val.intVal = packing;
- if (vlSetControl(vlSvr, vlPath, drn, VL_PACKING, &val) < 0)
- vlPerror("Getting VL_PACKING");
- }
-
- /* Set the graphics to the same packing as the video board */
- vlGetControl(vlSvr, vlPath, drn, VL_PACKING, &val);
- packing = val.intVal;
- switch (val.intVal)
- {
- case VL_PACKING_Y_8_P:
- /*
- * XXX -gordo
- * this needs to restore the colormap
- */
- {
- int i;
-
- /* Use colormap mode for greyscale */
- cmode();
- for (i = 0; i < 256; i++)
- mapcolor(i, i, i, i);
- pixmode(PM_SIZE, 8); /* Pixels are 8 bit Greyscale */
- gconfig(); /* Reconfigure graphics */
- }
- break;
-
- case VL_PACKING_RGB_332_P:
- pixmode(PM_SIZE, 9); /* Pixels are 8 bit RGB */
- break;
-
- case VL_PACKING_RBG_323:
- pixmode(PM_SIZE, 8);
- break;
-
- /* Unknown packing type, use RGB as the default */
- default:
- packing = val.intVal = VL_PACKING_RGB_8;
- if (vlSetControl(vlSvr, vlPath, drn, VL_PACKING, &val) < 0)
- vlPerror("Setting RGB");
- vlGetControl(vlSvr, vlPath, drn, VL_PACKING, &val);
- Debug("packing type now is %s\n", packing_name(val.intVal));
- if (val.intVal != packing)
- {
- fprintf(stderr, "%s: Error, could not set Packing to %s", _progName,
- packing_name (packing));
- exit(1);
- }
- /*
- * There is no break here intentionally... the packing should
- * now be VL_PACKING_RGB, and thus should fall through...
- */
- case VL_PACKING_RGB_8:
- case VL_PACKING_RGBA_8:
- break;
- }
-
-
- initialize();
- getorigin(&orgx, &orgy);
- leftmousedown = 0;
-
- /* Set up the ring buffer for data transfer */
- transferBuf = vlCreateBuffer(vlSvr, vlPath, drn, buffers);
-
- /* Associate the ring buffer with the path */
- vlRegisterBuffer(vlSvr, vlPath, drn, transferBuf);
-
- /* Set ProcessEvent() as the callback for a transfer complete event */
- vlAddCallback(vlSvr, vlPath, VLTransferCompleteMask|VLTransferFailedMask,
- ProcessEvent, NULL);
-
- vlRegisterHandler(vlSvr, qgetfd(), (VLEventHandler)ProcessGlEvent,
- (VLPendingFunc) qtest, (void *)win);
-
- if (vlBeginTransfer(vlSvr, vlPath, 0, NULL) < 0)
- {
- vlPerror("vlBeginTransfer");
- exit(1);
- }
-
- initStatistics();
-
- /* event loop */
-
-
- vlMainLoop();
-
- }
- void
- ProcessEvent(VLServer svr, VLEvent *ev, void *data)
- {
- int count;
- static int frameNum;
- static ulong lasttime = -1;
- static ulong lastsec;
- int timeDiff;
- DMediaInfo *dmInfo;
- VLInfoPtr info;
- char *dataPtr;
-
- /* Display the frame rate at a user specified interval */
- if (frameInterval > 0 && frameCount > frameInterval)
- {
- reportStatistics();
- frameCount = 0;
- }
-
- switch (ev->reason)
- {
- case VLTransferComplete:
- framenumber++;
-
- /* Get a pointer to the most recently captured frame */
- info = vlGetLatestValid(svr, transferBuf);
- if (!info)
- break;
-
- /* Get the valid video data from that frame */
- dataPtr = vlGetActiveRegion(svr, transferBuf, info);
-
- if (time_on)
- {
- dmInfo = vlGetDMediaInfo(svr, transferBuf, info);
- if (lasttime != -1)
- {
- timeDiff = (dmInfo->time.tv_sec - lastsec) * TIME_GRANULARITY;
- timeDiff += (int)(dmInfo->time.tv_usec - lasttime + 500) /
- (1000000 / TIME_GRANULARITY);
- if (timeDiff >= TIME_ARRAY_SIZE)
- timeDiff = TIME_ARRAY_SIZE-1;
- time_array[timeDiff] += 1;
- }
- lasttime = dmInfo->time.tv_usec;
- lastsec = dmInfo->time.tv_sec;
- }
-
- if (!fast)
-
-
- /* do some graphics here - this is part of the main loop */
- getframe = (ulong *)dataPtr;
- if (leftmousedown) {
- x = (short)(getvaluator(MOUSEX) - orgx - (xsize*pixscale)/2);
- y = (short)(getvaluator(MOUSEY)-orgy-(ysize*yzoommult*pixscale)/2);
- }/* endif leftmousedown */
- draw_scene(x,y);
-
- vlPutFree(svr, transferBuf);
- frameCount++;
- if (framenumber >= totalCount)
- exitcapture();
- break;
- case VLTransferFailed:
- printf("VL transfer failed\n");
- exitcapture();
- break;
- default:
- printf("Got Event %d\n", ev->reason);
- break;
- }
- }
-
-
- void
- ProcessGlEvent(int fd, void *win)
- {
- static short val;
- int loop;
- long device;
-
- while(qtest()){
- device = qread(&val);
- switch (device)
- {
- /* start rotate image cases here */
- case INPUTCHANGE:
- active = val;
- if (val);
- break;
- case LEFTMOUSE:
- leftmousedown = val; /* 1 if mouse button down */
- break;
- case MIDDLEMOUSE:
- switch (backcolor)
- {
- case 1:
- RGBcolor(0, 0, 255);
- break;
- case 2:
- RGBcolor(0, 255, 0);
- break;
- case 3:
- RGBcolor(255, 0, 0);
- break;
- case 4:
- RGBcolor(255, 255, 255);
- break;
- default:
- case 0:
- RGBcolor(0, 0, 0);
- break;
- }
- clear();
- break;
- case RIGHTMOUSE:
- if (val) {
- switch (dopup(menu)) {
- case 1:
- alpha = 0xff000000;
- doalpha = 0;
- break;
- case 2:
- alpha = 0x3f000000;
- doalpha = 1;
- break;
- case 3:
- alpha = 0x0f000000;
- doalpha = 1;
- break;
- case 4:
- x += xsize*pixscale/2;
- y += ysize*pixscale/2;
- pixscale = 1;
- x -= xsize/2;
- y -= ysize/2;
- rzoom = 1;
- break;
- case 5:
- if (effecttype == 0){
- x += xsize*pixscale/2;
- y += ysize*pixscale/2;
- pixscale = 2;
- x -= xsize*pixscale/2;
- y -= ysize*pixscale/2;
- rzoom = 2;
- }else
- printf("Zoom in paint mode only\n\a");
- break;
- case 6:
- if (effecttype == 0){
- x += xsize*pixscale/2;
- y += ysize*pixscale/2;
- pixscale = 4;
- x -= xsize*pixscale/2;
- y -= ysize*pixscale/2;
- rzoom = 4;
- }else
- printf("Zoom in paint mode only\n\a");
- break;
- case 7:
- drawcolors = 0;
- break;
- case 8:
- drawcolors = 1;
- break;
- case 9:
- drawcolors = 2;
- break;
- case 10:
- switch (backcolor)
- {
- case 1:
- RGBcolor(0, 0, 255);
- break;
- case 2:
- RGBcolor(0, 255, 0);
- break;
- case 3:
- RGBcolor(255, 0, 0);
- break;
- case 4:
- RGBcolor(255, 255, 255);
- break;
- default:
- case 0:
- RGBcolor(0, 0, 0);
- break;
- }
- clear();
- effecttype = 0;
- break;
- case 11:
- x += xsize*pixscale/2;
- y += ysize*pixscale/2;
- pixscale = 1;
- x -= xsize/2;
- y -= ysize/2;
- rectzoom(1.0,1.0);
- switch (backcolor)
- {
- case 1:
- RGBcolor(0, 0, 255);
- break;
- case 2:
- RGBcolor(0, 255, 0);
- break;
- case 3:
- RGBcolor(255, 0, 0);
- break;
- case 4:
- RGBcolor(255, 255, 255);
- break;
- default:
- case 0:
- RGBcolor(0, 0, 0);
- break;
- }
- clear();
- effecttype = 1;
- break;
- case 12:
- backcolor = backcolor + 1;
- if (backcolor > 4)
- backcolor = 0;
- switch (backcolor)
- {
- case 1:
- RGBcolor(0, 0, 255);
- break;
- case 2:
- RGBcolor(0, 255, 0);
- break;
- case 3:
- RGBcolor(255, 0, 0);
- break;
- case 4:
- RGBcolor(255, 255, 255);
- break;
- default:
- case 0:
- RGBcolor(0, 0, 0);
- break;
- }
- clear();
- break;
- case 13:
- gexit(); /* add for graphics */
- exitcapture();
- break;
- }
- }
- break;
- case REDRAW:
- reshapeviewport();
- getorigin(&orgx, &orgy);
- break;
- case DKEY :
- if (val == 1) {
- if (double_buffer = 1 - double_buffer) {
- doublebuffer();
- Debug("double buffer mode\n");
- }
- else {
- singlebuffer();
- Debug("single buffer mode\n");
- }
- gconfig();
- }
- break;
- case CKEY:
- if (val)
- {
- backcolor = backcolor + 1;
- if (backcolor > 4)
- backcolor = 0;
- switch (backcolor)
- {
- case 1:
- RGBcolor(0, 0, 255);
- break;
- case 2:
- RGBcolor(0, 255, 0);
- break;
- case 3:
- RGBcolor(255, 0, 0);
- break;
- case 4:
- RGBcolor(255, 255, 255);
- break;
- default:
- case 0:
- RGBcolor(0, 0, 0);
- break;
- }
- clear();
- }/* if val */
- break;
-
- /* Quit capture */
- case QKEY :
- if (val != 1){
- break;
- }
-
- case ESCKEY:
- case WINSHUT:
- case WINQUIT:
- gexit(); /* add for graphics */
- exitcapture();
- break;
- } /* end switch */
- } /* end if qtest */
- }/* end procedure */
-
- void
- exitcapture()
- {
- int loop, j;
-
- /* End the data transfer */
- vlEndTransfer(vlSvr, vlPath);
-
- /* Disassociate the ring buffer from the path */
- vlDeregisterBuffer(vlSvr, vlPath, drn, transferBuf);
-
- /* Destroy the path, free the memory it used */
- vlDestroyPath(vlSvr,vlPath);
-
- /* Destroy the ring buffer, free the memory it used */
- vlDestroyBuffer(vlSvr, transferBuf);
-
- /* Disconnect from the daemon */
- vlCloseVideo(vlSvr);
-
- /* Print the time stamps from the captured frames */
- if (time_on)
- for (loop = 0; loop < TIME_ARRAY_SIZE; ) {
- printf("%3d: ", loop);
- for (j = 0; j < 5; j++)
- printf("\t%d", time_array[loop++]);
- printf("\n");
- }
-
- exit(0);
- }
-
- /* === */
-